import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { UserExpansionVO, UserExpansionForm, UserExpansionQuery } from '@/api/logic/userExpansion/types';

/**
 * 查询用户列表
 * @param query
 * @returns {*}
 */

export const listUserExpansion = (query?: UserExpansionQuery): AxiosPromise<UserExpansionVO[]> => {
  return request({
    url: '/logic/userExpansion/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询用户详细
 * @param id
 */
export const getUserExpansion = (id: string | number): AxiosPromise<UserExpansionVO> => {
  return request({
    url: '/logic/userExpansion/' + id,
    method: 'get'
  });
};

export const changeUserStatus = (id: string | number, status: string) => {
  return request({
    url: '/logic/userExpansion/changeStatus',
    method: 'put',
    data: {
      userId: id,
      status: status
    }
  });
};

/**
 * 新增用户
 * @param data
 */
export const addUserExpansion = (data: UserExpansionForm) => {
  return request({
    url: '/logic/userExpansion',
    method: 'post',
    data: data
  });
};

/**
 * 修改用户
 * @param data
 */
export const updateUserExpansion = (data: UserExpansionForm) => {
  return request({
    url: '/logic/userExpansion',
    method: 'put',
    data: data
  });
};

/**
 * 删除用户
 * @param id
 */
export const delUserExpansion = (id: string | number | Array<string | number>) => {
  return request({
    url: '/logic/userExpansion/' + id,
    method: 'delete'
  });
};
